package com.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.entity.SupplierEntity;
import com.project.entity.SupplierRecordEntity;
import com.project.service.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("supplier")
public class SupplierController {

    @Autowired
    private ISupplierService service;

    @RequestMapping("findByItem")
    public IPage<SupplierEntity> findByItem(Integer pageNO, int status,int pageSize) {
        return service.findByItem(pageNO,status,pageSize);
    }

    @RequestMapping("findHistory")
    public List<SupplierRecordEntity> findByHistory(long id) {
        return service.findByHistory(id);
    }

    @RequestMapping("findById")
    public SupplierRecordEntity findById(Integer supplierRef) {
        return service.findByRef(supplierRef);
    }

    @RequestMapping("updateStatus")
    public String updateStatus(Integer supplierRef, int status,String cause) {
        service.updateStatus(supplierRef, status, cause);
        return "ok";
    }
}
